package arcane.object.game.sprite;

import java.awt.Graphics2D;
import java.awt.Transparency;
import java.awt.image.BufferedImage;


import com.golden.gamedev.util.ImageUtil;

public class SigilSprite extends MenuSprite {
	private static final BufferedImage highLite = ImageUtil.getImage(
			ClassLoader.getSystemResource("Images/Menu/glow.png"),
			Transparency.TRANSLUCENT);
	private static GeometricSprite[] cursors = new GeometricSprite[4];
	static {
		for (int i = 0; i < cursors.length; i++) {
			cursors[i] = new GeometricSprite(highLite, 0, 0);
			cursors[i].setAngleIncrement(i % 2 == 0 ? -.06f : .06f);
			cursors[i].setAngle(i * 45);
			cursors[i].setAlpha(.5f);
			cursors[i].setActive(false);
		}
	}
	float cursorAlpha;

	public SigilSprite(BufferedImage img, int x, int y) {
		super(img, x, y);
	}

	public void update(long time) {
		super.update(time);
		if (this.mouseOver) {
			cursorAlpha += .005;
			if (cursorAlpha > .1)
				cursorAlpha = .1f;
			for (int i = 0; i < cursors.length; i++) {
				cursors[i].setAlpha(cursorAlpha);
				cursors[i].update(time);
			}
		}
	}

	public void mouseEntered(int x, int y) {
		super.mouseEntered(x, y);
		int w = 100, h=100, x2 = (int)getX()-(w-getWidth())/2, y2=(int)getY()-(h-getHeight())/2;
		for (int i = 0; i < cursors.length; i++) {
			cursors[i].setLocation(x2,y2);
			cursors[i].setWidth(w);
			cursors[i].setHeight(h);
			cursors[i].setActive(true);
		}
	}

	public void mouseExited(int x, int y) {
		super.mouseExited(x, y);
		for (int i = 0; i < cursors.length; i++) {
			cursors[i].setActive(false);
		}
		cursorAlpha = 0;
	}

	public void render(Graphics2D g) {
		for (int i = 0; i < cursors.length; i++) {
			cursors[i].render(g);
		}
		super.render(g);

	}
}